package org.eae.eldf.dao.sys.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.eae.eldf.dao.sys.ISysSequenceDao;
import org.eae.eldf.dto.sys.SysSequenceQueryDto;
import org.eae.eldf.entity.sys.SysSequence;
import org.eae.eldf.framework.dao.JdbcDaoImpl;
import org.eae.eldf.framework.pager.Pagination;
import org.springframework.stereotype.Repository;
@Repository
public class SysSequenceDaoImpl extends JdbcDaoImpl implements ISysSequenceDao{

	@Override
	public Pagination<SysSequence> queryListSysSequence(
			Pagination<SysSequence> pager, SysSequenceQueryDto sysSequenceQueryDto) {
		// TODO Auto-generated method stub
		String sql = "select * from sys_sequence s ";
		List<Object> params=new ArrayList<Object>();
		if(null != sysSequenceQueryDto ){
		if (sysSequenceQueryDto.getSeqCode() != null) {
			sql+=" where s.seq_code like ?";
			params.add("%"+sysSequenceQueryDto.getSeqCode()+"%");
		}
		if(StringUtils.isNotBlank(pager.getOrderBy()) && StringUtils.isNotBlank(pager.getSort())){
			sql+=" order by "+pager.getOrderBy().toUpperCase()+" "+pager.getSort().toUpperCase();
		}else{
			sql+=" order by s.create_time desc";
		}
		}
		return this.queryListByPage(pager, sql,params,SysSequence.class);
	}
		

}
